Skip to content

Allow users to set request option headers for Anthropic's LLMs #4785

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

FallDownTheSystem
Copy link
Contributor

@FallDownTheSystem FallDownTheSystem commented Mar 24, 2025

Description

Allow users to set request option headers for Anthropic's LLMs and add special handling for anthropic-beta headers

Checklist

  • The relevant docs, if any, have been updated or created
  • The relevant tests, if any, have been updated or created

Screenshots

No visual changes

Testing instructions

Add

"requestOptions": {
  "headers": {
    "anthropic-beta": "output-128k-2025-02-19"
  }
}

for the claude-3-7-sonnet-20250219 model, enable extended thinking, and ask it to think for as long as possible. You should see it go well past the typical 8k output token limit.

@FallDownTheSystem FallDownTheSystem requested a review from a team as a code owner March 24, 2025 15:48
@FallDownTheSystem FallDownTheSystem requested review from RomneyDa and removed request for a team March 24, 2025 15:48
Copy link

netlify bot commented Mar 24, 2025

Deploy Preview for continuedev ready!

Name Link
🔨 Latest commit a3fa888
🔍 Latest deploy log https://app.netlify.com/sites/continuedev/deploys/6815d0c9d14d110008d85e7f
😎 Deploy Preview https://deploy-preview-4785--continuedev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Collaborator

@RomneyDa RomneyDa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@FallDownTheSystem requestOptions is injected by this.fetch which uses the customFetch from the @continuedev/fetch package. This is pretty easy to miss

The anthropic beta changes look interesting, could you update it to just add them to this.requestOptions rather than spreading request option headers?

@FallDownTheSystem
Copy link
Contributor Author

Oh I see. So the requestOption headers were always set, but they would overwrite the anthropic-beta header, so the prompt-caching wouldn't be set.

I did get another idea, you could set the output-128k-2025-02-19 value here automatically if the user has defined over 8k (or over 64k if reasoning is enabled) as their maxTokens.

@RomneyDa
Copy link
Collaborator

@FallDownTheSystem following up, apologies for the delays, these changes look like the right approach, could you check the conflicts?

@RomneyDa RomneyDa requested review from sestinj and removed request for RomneyDa May 3, 2025 05:30
@FallDownTheSystem FallDownTheSystem requested a review from RomneyDa May 3, 2025 08:15
Copy link
Contributor

@sestinj sestinj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of the code itself looks perfect, thanks @FallDownTheSystem! Would you be able to quickly add a test for the setBetaHeaders method? It would be fine to do this in an adjacent Anthropic.test.ts file, make the method public, and just include ~2 test cases

@sestinj
Copy link
Contributor

sestinj commented May 12, 2025

Just wanted to check in on this. Definitely hoping to get tests in this PR, and if you need help just let me know!

@sestinj
Copy link
Contributor

sestinj commented May 26, 2025

Hey @FallDownTheSystem, I'm going to close this PR for now since I haven't heard back. If you'd like some help getting the tests over the line, just let me know and I'm happy to help out

@sestinj sestinj closed this May 26, 2025
@github-actions github-actions bot locked and limited conversation to collaborators May 26, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants